﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Omes.Model;
using Omes.Services;

namespace Omes.Web.CustomerControls
{
    public partial class HtmlControl : System.Web.UI.UserControl, ICustomControl
    {
        public int PageId { set; get; }
        public int BlockName { set; get; }
        public string ItemAction { set; get; }
        public string ChildAction { set; get; }

        public List<Omes.Model.Page> ChildPages { set; get; }
        public string OrganizationName { set; get; }
        public Omes.Model.Page CurrentPage { set; get; }
        public string HtmlText { set; get; }
        public string ContactDesc { set; get; }
        private IPageService pageService;
        private IResourceService resouceService;
        protected void Page_Load(object sender, EventArgs e)
        {
            //todo：获取数据
            ChildPages = pageService.GetChildPage(PageId);
            CurrentPage = pageService.GetPage(PageId);
            string htmlstr = string.Empty;
            if(CurrentPage.DisplaySelf=="true")
            {
                Html html = resouceService.GetHtml(PageId, null);
                htmlstr = html.Content;
                OrganizationName = CurrentPage.PageName;
            }
            else
            {
                Html html = resouceService.GetHtml(ChildPages[0].Id, null);
                htmlstr = html.Content;
                OrganizationName = CurrentPage.PageName;
                CurrentPage = ChildPages[0];
            }
            HtmlText = htmlstr;
            ContactDesc = "<br/>123123123<br/>123123123123<br/>123123123<br/>123123123123";
        }
    }
}